import { get, post } from '../utils/request'

// 获取主题分类列表
export const getClassList = () => {
  // return get('/topic/classList')
  return get('/topic/topicList')
}

// 获取主题列表
export const getTopicList = ({ queryKey, pageParam = 1 }) => {
  const [, classId] = queryKey
  return get('/topic/list', { classId, page: pageParam })
}

// 获取热门主题列表
export const getHotTopicList = ({ queryKey, pageParam = 1 }) => {
  const [, id] = queryKey
  return get('/topic/hot', { limit: 10, page: pageParam })
}

// 获取主题详情
export const getTopicDetail = ({ queryKey }) => {
  const [, id] = queryKey
  return get('/topic/detail', { id })
}

// 获取话题列表
export const getDiscussList = ({ queryKey, pageParam = 1 }) => {
  const [, id] = queryKey
  return post('/discuss/list', { topicId: id, page: pageParam })
}

// 获取话题详情
export const getDiscussDetail = ({ queryKey }) => {
  const [, id] = queryKey
  return get('/discuss/detail', { id })
}

// 用户/我加入的主题 uid不传默认当前用户
export const postUserJoinTopic = async (params) => {
  return post('/topic/userJoinTopic', params)
}

// 创建主题
export const fetchCreateTopic = async (params) => {
  return post('/topic/topicAdd', params)
}

// 退出主题
export const fetchExitTopic = async (params) => {
  return get('/topic/userTopicDel', params)
}
// 加入主题
export const fetchJoinTopic = async (params) => {
  return get('/topic/joinTopic', params)
}

// 加入主题验证
export const fetchJoinTopicApply = async (params) => {
  return post('/topic/joinTopicApply', params)
}

// 编辑主题
export const fetchEditTopic = async (params) => {
  return post('/topic/topicEdit', params)
}

// 解散主题
export const fetchDeleteTopic = async (params) => {
  return get('/topic/topicDel', params)
}

// 获取主题成员
export const fetchTopicMember = async ({ queryKey, pageParam = 1 }) => {
  const [, id] = queryKey
  return post('/topic/userList', { id, page: pageParam })
}

// 踢出主题
export const fetchTopicMemberDel = async (params) => {
  return post('/user/removeTopic', params)
}

// 设置管理员
export const fetchTopicMemberSetAdmin = async (params) => {
  return post('/post/setAdmin', params)
}

// 拉入黑名单
export const fetchTopicMemberBlacklist = async (params) => {
  return post('/topic/doBlock', params)
}

// 移出黑名单
export const fetchTopicMemberOutBlacklist = async (params) => {
  return post('/topic/removeBlock', params)
}

// 获取黑名单列表
export const fetchTopicMemberBlacklistList = async ({ queryKey, pageParam = 1 }) => {
  const [, id] = queryKey
  return post('/topic/blockUserList', { id, page: pageParam })
}

// 取消管理员
export const fetchTopicMemberCancelAdmin = async (params) => {
  return post('/post/cancelAdmin', params)
}

// 删除话题
export const fetchDiscussDel = async (params) => {
  return post('/discuss/del', params)
}

// 创建话题
export const fetchDiscussAdd = async (params) => {
  return post('/discuss/addDis', params)
}

// 转让圈主
export const fetchTopicTransfer = async (params) => {
  return post('/topic/giveTopic', params)
}

// 获取热门话题
export const getHotDiscuss = () => {
  return get('/discuss/hotDiscussList')
}

// 主题管理员获取进圈验证
export const fetchTopicJoinVerify = async ({ queryKey }) => {
  const [, id] = queryKey
  return get('/topic/checkTopicApplyByAdmin', { topicId: id })
}

// 获取进圈验证列表
export const fetchTopicJoinVerifyList = async ({ queryKey, pageParam = 1 }) => {
  const [, id, type] = queryKey
  return post('/topic/applyInfoList', { topicId: id, page: pageParam, type, limit: 10 })
}

// 同意进圈验证
export const fetchTopicJoinVerifyAgree = async (params) => {
  return post('/topic/agreeApply', params)
}

// 拒绝进圈验证
export const fetchTopicJoinVerifyReject = async (params) => {
  return post('/topic/rejectApply', params)
}

// 设置主题模板风格
export const setTemplateStyle = (params) => {
  return get('/topic/setTemplateStyle',params)
}